import pandas as pd

import openpyxl, numexpr, bottleneck

print(f"openpyxl版本：{openpyxl.__version__}")  # 应≥3.1.0
print(f"numexpr版本：{numexpr.__version__}")    # 应≥2.8.4
print(f"bottleneck版本：{bottleneck.__version__}")  # 应≥1.3.6




file_path = '1.xlsx'

sheet1 = pd.read_excel(file_path, sheet_name='Sheet1')
sheet2 = pd.read_excel(file_path, sheet_name='Sheet2')

sheet1.columns = sheet1.columns.str.strip()
sheet2.columns = sheet2.columns.str.strip()

# 合并数据
merged_data = sheet1.merge(sheet2[['Person', '身高', '体重', '国籍', '连任次数']], on='Person', how='left')

print("merged_data 列名:", merged_data.columns.tolist())

sheet1['身高'] = merged_data['身高_y']
sheet1['体重'] = merged_data['体重_y']
sheet1['国籍'] = merged_data['国籍_y']
sheet1['连任次数'] = merged_data['连任次数_y']


with pd.ExcelWriter('1_updated.xlsx') as writer:
    sheet1.to_excel(writer, sheet_name='Sheet1', index=False)
    sheet2.to_excel(writer, sheet_name='Sheet2', index=False)







